import request from '@/utils/request'
import { getToken } from '@/utils/auth'

const bURL = 'http://10.61.22.44:8889/brother_hood/backstage/public/order/'

/*
  分页获取所有订单
 */
export function getOrders(page, pageSize) {
  return request({
    headers: {
      'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MzE4MTAyNTYsImV4cCI6MTYzNTQxMDI1Niwic2lnbiI6Ik1RPT0iLCJkYXRhIjp7InVpZCI6MX19.aCkiokwgjzU8aF6UIQbei1xUwHPOB8IEGeP5bac4Iwo'
    },
    baseURL: bURL,
    url: 'getOrders',
    method: 'get',
    params: {
      'page': page,
      'pageSize': pageSize
    }
  })
}

/*
  获取所有物流公司
 */
export function getLogisticsCompany() {
  return request({
    headers: {
      'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MzE4MTAyNTYsImV4cCI6MTYzNTQxMDI1Niwic2lnbiI6Ik1RPT0iLCJkYXRhIjp7InVpZCI6MX19.aCkiokwgjzU8aF6UIQbei1xUwHPOB8IEGeP5bac4Iwo'
    },
    baseURL: bURL,
    url: 'getLogisticsCompany',
    method: 'get',
    params: {}
  })
}

/*
  选择物流公司，进行发货
 */
export function doDelivery(oid, comp) {
  return request({
    headers: {
      'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MzE4MTAyNTYsImV4cCI6MTYzNTQxMDI1Niwic2lnbiI6Ik1RPT0iLCJkYXRhIjp7InVpZCI6MX19.aCkiokwgjzU8aF6UIQbei1xUwHPOB8IEGeP5bac4Iwo'
    },
    baseURL: bURL,
    url: 'doDelivery',
    method: 'put',
    params: {
      id: oid,
      delivery_company: comp
    }
  })
}
